package net.bezrabotnih.cabinet.client.ui;



import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;

public class CommentsPanel extends Composite {

	private static CommentsPanelUiBinder uiBinder = GWT
			.create(CommentsPanelUiBinder.class);

	interface CommentsPanelUiBinder extends UiBinder<Widget, CommentsPanel> {
	}
	
	@UiField
	TextArea textArea;
	
	@UiField
	Button button;
	
	@UiField
	VerticalPanel comments;
	

	public CommentsPanel() {
		initWidget(uiBinder.createAndBindUi(this));
	}


	public String getNewComment() {
		return textArea.getText();
	}

	
	public void addComment(String thumbnailUrl,String name,String text){
		CommentBlock commentBlock=new CommentBlock(thumbnailUrl, name, text);
		comments.insert(commentBlock, 0);
		textArea.setValue("");
//		comments.add(commentBlock);
//		System.out.println("commentblock inserted");
	
	}
	
	public void addSubmitButtonClickListener(ClickHandler listener){
		button.addClickHandler(listener);
		
	}
	
	
	
	
	

}
